/*
 * @Author: kaikaima
 * @Date: 2021-03-01 09:49:44
 * @LastEditTime: 2021-03-01 09:52:53
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /undefined/home/messi/Data_Structure_and_Algorithm_GIT/PAT/Basic_level/1010.cpp
 */
/*设计函数求一元多项式的导数。（注：x​n​​（n为整数）的一阶导数为nx​n−1​​。）
  输入格式:
  以指数递降方式输入多项式非零项系数和指数（绝对值均为不超过 1000 的整数）。数字间以空格分隔。
  输出格式:
  以与输入相同的格式输出导数多项式非零项的系数和指数。数字间以空格分隔，但结尾不能有多余空格。注意“零多项式”的指数和系数都是 0，但是表示为 0 0。*/
#include <iostream>
#include <stdio.h>

class term{
    private:
        class Node{
            public:
            int coeff;//系数
            int index;//指数
            Node* next;
            Node() {next=NULL;};
            Node(int _a, int _b) {coeff=_a; index=_b; next=NULL;};
        };
        Node* head;
    public:
        term() {head=NULL;};
        ~term();
        void insert(int _a, int _b);
        void derivation();//求导
        void output();
};

term::~term(){
    Node* p=head;
    while(p!=NULL){
        Node* del=p;
        p=p->next;
        delete del;
    }
};

void term::insert(int _a, int _b){
	Node* p=new Node(_a,_b);
    if(head==NULL) head=p;
    else{
        Node* q=head;
        while(q->next!=NULL) {q=q->next;}
        q->next=p;
    }
};

void term::derivation(){
    Node* p=head;
    while(p!=NULL){
        p->coeff*=p->index;
        p->index--;
        p=p->next;
    }
};

void term::output(){
    if(head==NULL) std::cout<<"Error!"<<std::endl;
    else if(head->index<0) std::cout<<"0 0"<<std::endl;
    else{
        std::cout<<head->coeff<<" "<<head->index;
        Node* p=head->next;
        while(p!=NULL&&p->index>=0){
            std::cout<<" "<<p->coeff<<" "<<p->index;
            p=p->next;
        }
        std::cout<<std::endl;
    }
};

int main (int argc, char* argv[]){
    term key; char c;
    do{
        int a,b;
        std::cin>>a; std::cin>>b;
        key.insert(a,b);
        c=getchar();//接收数之间的空格
    }while(c!='\n');
    key.derivation();
    key.output();
    return 0;
}